package com.gyg.controller;


import com.gyg.returns.RespEntity;
import com.gyg.returns.RespTable;
import com.gyg.service.CloudRecordService;
import com.gyg.vo.result.CountResult;
import com.gyg.vo.result.RecordResult;
import io.swagger.annotations.Api;

import java.util.List;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 文件上传下载记录表 前端控制器
 * </p>
 *
 * @author gyg
 * @since 2021-04-14
 */
@RestController
@RequestMapping("/cloud-record")
@Api(value = "记录模块", tags = "记录模块")
@Slf4j
public class CloudRecordController {

    @Resource
    private CloudRecordService cloudRecordService;

    @GetMapping("/list")
    @ApiOperation(value = "记录列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "optionType", value = "操作类型(1=上传，2=下载)", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "page", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "每页数量", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "username", value = "用户账号", required = false)
    })
    public RespTable<List<RecordResult>> cloudRecordList(@RequestParam(value = "optionType", required = true) Integer optionType,
                                                         @RequestParam(value = "page", required = true) Integer page,
                                                         @RequestParam(value = "limit", required = true) Integer limit,
                                                         @RequestParam(value = "username", required = false) String username) {
        RespTable<List<RecordResult>> respTable = cloudRecordService.cloudRecordList(optionType, page, limit, username);
        return respTable;
    }

    @GetMapping("/uploadCount")
    @ApiOperation(value = "文件上传统计")
    public RespEntity<CountResult> uploadCount() {
        RespEntity<CountResult> respEntity = cloudRecordService.uploadCount();
        return respEntity;
    }

    @GetMapping("/downloadCount")
    @ApiOperation(value = "文件下载统计")
    public RespEntity<CountResult> downloadCount() {
        RespEntity<CountResult> respEntity = cloudRecordService.downloadCount();
        return respEntity;
    }

}
